<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button>div中的buttn</button>
    <div>
        div元素
        <p>div中的p元素</p>
    </div>
        

    <script>
        //1.获取元素， 使用html5中新的方法
        var div = document.querySelector('div');
        var btn = document.querySelector('button');
        //注册时间
        btn.onclick = function() {
            // div.innerText = getDate();
            // div.innerText = '<strong>今天是：</strong>' + getDate();
            div.innerHTML = '<strong>今天是：</strong>' + getDate();
        }

        function getDate() {
            var date = new Date();
            return '当前时间' + date.getFullYear() + '-' + (date.getMonth()+1) + '-' + date.getDate();
        }

        console.log('innerText=====' + div.innerText);
        console.log('innerHTML=====' + div.innerHTML);
    </script>
</body>
</html>